const cors = require("cors");
const express = require("express");
const app = express();
app.use(cors());
app.use(express.json());
const OSS = require("ali-oss");
const STS = OSS.STS;
const sts = new STS({
    accessKeyId: "LTAI5tPnzWmsJWf7GDoNvU3w",
    accessKeySecret: "SgAY4jXXnn7Sk7nvEhuRqlcsLYp3R3",
});
/* const config = {
    region: "oss-cn-beijing",
    accessKeyId: "LTAI5tPnzWmsJWf7GDoNvU3w",
    accessKeySecret: "SgAY4jXXnn7Sk7nvEhuRqlcsLYp3R3",
    bucket: "lineo-pet-oss",
};
const client = new OSS(config); */
app.get("/getOssSignature", async (_, res) => {
    const { credentials } = await sts.assumeRole(
        "acs:ram::1429380515992758:role/ramosstest", // role arn
        null, // policy
        15 * 60, // expiration
        "web-client" // session name
    );

    res.json({
        code: 200,
        credentials,
        message: "获取签名成功",
    });
});
app.listen(3000, () => {
    console.log("Server is running on port 3000");
});
